package com.dianrui.operation.activity;

import android.graphics.Canvas;
import android.widget.TextView;

import com.dianrui.operation.R;
import com.joanzapata.pdfview.PDFView;
import com.joanzapata.pdfview.listener.OnDrawListener;
import com.joanzapata.pdfview.listener.OnLoadCompleteListener;
import com.joanzapata.pdfview.listener.OnPageChangeListener;

import butterknife.BindView;
import butterknife.OnClick;

public class ShowPdfActivity extends BaseActivity implements OnPageChangeListener,OnLoadCompleteListener, OnDrawListener {
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.pdfview)
    PDFView pdfview;

    @Override
    public int getContentViewId() {
        return R.layout.show_pdf;
    }

    @Override
    public void initView() {
        title.setText("操作指南");
        displayFromAssets();
    }

    @Override
    public void initData() {

    }


    private void displayFromAssets() {
        pdfview.fromAsset("op_use.pdf")   //设置pdf文件地址
                .defaultPage(1)         //设置默认显示第1页
                .onPageChange(this)     //设置翻页监听
                .onLoad(this)           //设置加载监听
                .onDraw(this)            //绘图监听
                .showMinimap(false)     //pdf放大的时候，是否在屏幕的右上角生成小地图
                .swipeVertical(true )  //pdf文档翻页是否是垂直翻页，默认是左右滑动翻页
                .enableSwipe(true)   //是否允许翻页，默认是允许翻页
                .load();
    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void onLayerDrawn(Canvas canvas, float pageWidth, float pageHeight, int displayedPage) {

    }

    @Override
    public void loadComplete(int nbPages) {

    }

    @Override
    public void onPageChanged(int page, int pageCount) {

    }
}
